﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace BaoJian.Control.local
{
    /// <summary>
    /// 地方版健康品排名
    /// </summary>
    public partial class ProductRanking : System.Web.UI.UserControl
    {
        public int Count;
        public string ColumnID;
        public int ImageWidth = 109;
        public int ImageHeight = 58;
        public int TitleLength = 10;
        public string Region;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string sql = "SELECT TOP {0} sid,oid,pid,left(title,{1}) as title ,summary,ctime,FirstSmallimage FROM doc WHERE Region='{2}'AND PID='{3}' AND  publish=1 ORDER BY Recommand desc, CTime DESC";
                sql = string.Format(sql, Count, TitleLength, Region, ColumnID);
                DataSet ds = Maticsoft.DBUtility.DbHelperSQL.Query(sql);
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                DataRowCollection drc = ds.Tables[0].Rows;

                for (int i = 0; i < Count && i < drc.Count; i++)
                {
                    DataRow dr = drc[i];
                    if (i == 0)
                    {
                        string path = (dr["FirstSmallimage"] as string).Replace("~", "..\\");
                        sb.Append("<ul><li class=\"one\"><br /><a target=\"_blank\" href=\"c.aspx?id=" + dr["oid"] as string + "\">" + dr["title"] as string + "</a><br />");
                        sb.Append("<a target=\"_blank\" href=\"/c.aspx?id=" + dr["oid"] as string + "\"><img height=\"" + ImageHeight + "\" width=\"" + ImageWidth + "\"  src=\"" + path + "\"/></a></li>");
                    }
                    else
                    {
                        sb.Append("<li><span>" + (i + 1) + "</span><a  target=\"_blank\" href=\"/c.aspx?id=" + dr["oid"] as string + "\">" + dr["title"] as string + "</a></li>");
                    }
                }
                sb.Append("</ul>");
                Literal1.Text = sb.ToString();
            }
        }
    }
}